import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
//加急

main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        primaryColor: Color.fromRGBO(51, 51, 51, 1),
      ),
      home: HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Color.fromRGBO(236, 236, 236, 1),
      appBar: AppBar(
          titleSpacing: 0.0,
          title: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              FlatButton(
                materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
                child: Row(
                  children: [
                    Icon(
                      Icons.arrow_back_ios,
                      color: Colors.white,
                    ),
                    Text(
                      '返回',
                      style: TextStyle(color: Colors.white, fontSize: 16),
                    )
                  ],
                ),
                onPressed: () {
                  Navigator.pop(context);
                },
              ),
              Container(
                child: Row(
                  children: [
                    Text(
                      '跑腿订单详情',
                      style: TextStyle(fontSize: 16),
                    ),
                    SizedBox(
                      width: 30,
                    )
                  ],
                ),
              ),
              IconButton(icon: Icon(Icons.more_horiz), onPressed: () {})
            ],
          )),
      body: Subject(),
      floatingActionButton: FlatButton(
          color: Colors.grey,
          child: Container(
            child: Text(
              "我要接单",
              style: TextStyle(color: Colors.white),
            ),
            height: 50,
            alignment: Alignment(0, 0),
          ),
          onPressed: () {
            showDialog(
                context: context,
                barrierDismissible: false,
                builder: (cont) {
                  return MyDiaLog();
                });
          }),
      floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
    );
  }
}

class Subject extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      height: 400,
      color: Colors.white,
      padding: EdgeInsets.only(top: 10, bottom: 10, left: 25, right: 25),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
              Text(
                "跑腿 加急",
                style: TextStyle(fontSize: 15),
              ),
              Text(
                "待接单",
                style: TextStyle(color: Colors.red, fontSize: 15),
              ),
            ],
          ),
          Container(
            margin: EdgeInsets.only(top: 10, bottom: 10),
            child: Text(
              "任务主题（限制20字）",
              style: TextStyle(fontSize: 20),
            ),
          ),
          Row(
            children: <Widget>[
              Container(
                width: 50,
                height: 50,
                margin: EdgeInsets.only(right: 10),
                alignment: Alignment.center,
                decoration: BoxDecoration(
                    border: Border.all(
                      color: Colors.grey,
                    ),
                    borderRadius: BorderRadius.all(Radius.circular(25))),
                child: Text("头像"),
              ),
              Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Text(
                    "发单人姓名",
                    style: TextStyle(fontSize: 15),
                  ),
                  Text(
                    "厦门大学",
                    style: TextStyle(fontSize: 15),
                  ),
                ],
              ),
            ],
          ),
          Container(
            height: 1,
            margin: EdgeInsets.only(top: 10, bottom: 10),
            decoration: BoxDecoration(
              color: Colors.grey.withOpacity(0.3),
              borderRadius: BorderRadius.all(Radius.circular(1)),
            ),
          ),
          Container(
            // padding: EdgeInsets.only(top: 10),
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Icon(
                  Icons.monetization_on,
                  color: Colors.grey,
                ),
                SizedBox(
                  width: 5,
                ),
                Flexible(
                  child: Text("跑腿费：7元"),
                )
              ],
            ),
          ),
          Container(
            padding: EdgeInsets.only(top: 10),
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Icon(
                  Icons.chat,
                  color: Colors.grey,
                ),
                SizedBox(
                  width: 5,
                ),
                Flexible(
                  child: Text("任务内容任务内容任务内容任务内容任务内容任务内容任务内容任务内容"),
                )
              ],
            ),
          ),
          Container(
            padding: EdgeInsets.only(top: 10),
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                SizedBox(
                  width: 28,
                ),
                Flexible(
                  child: Text(
                    "福建省厦门市思明区*****",
                    style: TextStyle(fontSize: 12),
                  ),
                )
              ],
            ),
          ),
          Container(
            height: 1,
            margin: EdgeInsets.only(top: 10, bottom: 10),
            decoration: BoxDecoration(
              color: Colors.grey.withOpacity(0.3),
              borderRadius: BorderRadius.all(Radius.circular(1)),
            ),
          ),
          Container(
            padding: EdgeInsets.only(top: 10),
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Icon(
                  Icons.phone_android,
                  color: Colors.grey,
                ),
                SizedBox(
                  width: 5,
                ),
                Flexible(
                  child: Text("139****8888"),
                )
              ],
            ),
          ),
          Container(
            height: 1,
            margin: EdgeInsets.only(top: 10, bottom: 10),
            decoration: BoxDecoration(
              color: Colors.grey.withOpacity(0.3),
              borderRadius: BorderRadius.all(Radius.circular(1)),
            ),
          ),
          Container(
            padding: EdgeInsets.only(top: 10),
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Icon(
                  Icons.query_builder,
                  color: Colors.grey,
                ),
                SizedBox(
                  width: 5,
                ),
                Flexible(
                  child: Text("发布时间：2017-6-20 18:00"),
                )
              ],
            ),
          ),
        ],
      ),
    );
  }
}

class MyDiaLog extends Dialog {
  @override
  Widget build(BuildContext context) {
    return SimpleDialog(
      children: <Widget>[
        Container(
          padding: EdgeInsets.only(top: 20, bottom: 20),
          alignment: Alignment.center,
          child: Text(
            "接单后，请尽快前往完成任务哦！",
            style: TextStyle(fontSize: 15),
          ),
        ),
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: <Widget>[
            Container(
              height: 40,
              width: 120,
              decoration: BoxDecoration(
                border: Border.all(color: Colors.grey),
              ),
              child: FlatButton(
                child: Text("确认接单"),
                onPressed: () {
                  Navigator.of(context).pop();
                },
              ),
            ),
            Container(
              height: 40,
              width: 120,
              decoration: BoxDecoration(
                border: Border.all(color: Colors.grey),
              ),
              child: FlatButton(
                child: Text("取消"),
                onPressed: () {
                  Navigator.of(context).pop();
                },
              ),
            ),
          ],
        ),
      ],
    );
  }
}
